﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Stockholm.SOA.Kaskelot.WCF.ServiceContracts;
using Stockholm.SOA.Kaskelot.WCF.DataContracts;
using Kaskelot.SP.Core;
using System.ServiceModel;
using Stockholm.SOA.Kaskelot.WCF.FaultContracts;

namespace Kaskelot.SP.Services
{
	public class LookupService : BaseService<IKaskelotService>
	{
		public ByggnadSearchLookupResult GetByggnadSearchLookupData()
		{
			ByggnadSearchLookupResult result = new ByggnadSearchLookupResult();
			try
			{
				result = this.channel.GetByggnadSearchLookupData(ApplicationContext.Current.Val.Id);
			}
			catch (FaultException<ErrorInformation> ex)
			{
                Logger.LogError(this, LayerNames.Services, "GetByggnadSearchLookupData", "Error getting lookupdata for search byggnad", ex);
			}

			return result;
		}

		public PersonSearchLookupResult GetPersonSearchLookupData()
		{
			PersonSearchLookupResult result = new PersonSearchLookupResult();
			try
			{
				result = this.channel.GetPersonSearchLookupData(ApplicationContext.Current.Val.Id);
			}
			catch (FaultException<ErrorInformation> ex)
			{
                Logger.LogError(this, LayerNames.Services, "GetPersonSearchLookupData", "Error getting lookupdata for search person", ex);
			}

			return result;
		}

		public IEnumerable<MaterielTyp> GetMaterielTypLookupData()
		{
			IEnumerable<MaterielTyp> result = null;

			try
			{
				result = this.channel.GetMaterielTypLookupData(ApplicationContext.Current.Val.Id);
			}
			catch (FaultException<ErrorInformation> ex)
			{
                Logger.LogError(this, LayerNames.Services, "GetMaterielTypLookupData", "Error getting lookupdata for materieltyp", ex);
			}

			return result;
		}

		public IList<MaterielTyp> GetPublicMaterielTypList()
		{
			IList<MaterielTyp> result = null;

			try
			{
				result = this.channel.GetPublicMaterielTypList(ApplicationContext.Current.Val.Id);
			}
			catch (FaultException<ErrorInformation> ex)
			{
				Logger.LogError(this, LayerNames.Services, "GetPublicMaterielTypList", "Error getting public materieltyp", ex);
			}

			return result;
		}

		public VakansSearchLookupResult GetVakansSearchLookupData()
		{
			VakansSearchLookupResult result = new VakansSearchLookupResult();
			try
			{
				result = this.channel.GetVakansSearchLookupData(ApplicationContext.Current.Val.Id);
			}
			catch (FaultException<ErrorInformation> ex)
			{
                Logger.LogError(this, LayerNames.Services, "GetVakansSearchLookupData", "Error getting lookupdata for search vakans", ex);
			}

			return result;
		}
	}
}
